#include<string>
#include<fstream>
#include<iostream>
using namespace std;

int main(int argc, char* argv[])
{
    const string log_name =  (argc==2)? argv[1] : "cmd.log";

    ofstream logfile;
    logfile.open(log_name);
    while( !cin.eof() )
    {
        string line;
        getline(cin, line);
        line +='\n';
        logfile << line;
        cout    << line;
    }
    logfile.close();
    return 0;
}

